using System;
using XDQ.VAT.EntityFrameworkCore;
using Volo.Abp.Domain.Repositories.EntityFrameworkCore;
using Volo.Abp.EntityFrameworkCore;
using System.Threading.Tasks;
using System.Collections.Generic;
using System.Linq;
using Microsoft.EntityFrameworkCore;

namespace XDQ.VAT.Courses
{
    public class AppCourseRepository : EfCoreRepository<VATDbContext, AppCourse, Guid>, IAppCourseRepository
    {
        public AppCourseRepository(IDbContextProvider<VATDbContext> dbContextProvider) : base(dbContextProvider)
        {
        }

        public async Task<IQueryable<AppCourse>> GetEnabledQueryableAsync()
        {
            var iq = await base.GetQueryableAsync();
            return iq.Where(x => x.IsEnabled == true);
        }


        public async Task<List<SelectListItemDto>> GetSelectListsAsync()
        {
            var iq = await this.GetEnabledQueryableAsync();
            return await iq.Select(x => new SelectListItemDto
            {
                Value = x.Id.ToString(),
                Text = x.Name
            }).ToListAsync();
        }
    }
}